let arr=[1,3,100,15,18,20]

console.log(arr);

console.log(arr.sort(function(x,y){
    if(x<y){
        return -1;
    }
    if(x===y){
        return 0
    }
    if(x>y){
        return 1;
    }
}));

console.log(arr);

let ar=[
    {
        name:'yyyy',
        age:20,
    },
    {
        name:'张三',
        age:10,
    },
    {
        name:'李四',
        age:120,
    },
    {
        name:'王五',
        age:109,
    },
]

console.log(ar);

console.log(
    arr.sort(function(x,y){
        return x.age - y.age
    }),
);

console.log(ar);